package com.qiaofang.service.impl;

import com.qiaofang.common.config.SystemConfig;
import com.qiaofang.common.constant.CommonResponseCode;
import com.qiaofang.common.response.CommonResponse;
import com.qiaofang.common.utils.StringUtil;
import com.qiaofang.dto.PremisesRecommenderDTO;
import com.qiaofang.entity.OtherCompany;
import com.qiaofang.entity.Premises;
import com.qiaofang.entity.enums.PremisesStatusEnum;
import com.qiaofang.entity.enums.SaleStatusEnum;
import com.qiaofang.mapper.PremisesRecommenderMapper;
import com.qiaofang.service.*;
import com.qiaofang.v10dto.SyncIntentionRecommenderReqDto;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import tk.mybatis.mapper.entity.Example;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

@Service
public class PremisesRecommenderServiceImpl implements PremisesRecommenderService {

    @Autowired
    private PremisesRecommenderMapper premisesRecommenderMapper;

    @Override
    public List<SyncIntentionRecommenderReqDto> selectListForIntentionRecommender(Long premisesId) {
        List<PremisesRecommenderDTO> dtoList = premisesRecommenderMapper.selectListForPremisesInfo(premisesId);
        List<SyncIntentionRecommenderReqDto> reqDtoList = dtoList.stream().map(temp -> {
            SyncIntentionRecommenderReqDto obj = new SyncIntentionRecommenderReqDto();
            if(StringUtils.isNotBlank(temp.getParentDeptName())){
                obj.setRecommenderDeptName(temp.getParentDeptName()+"-"+temp.getDeptName());
            }else{
                obj.setRecommenderDeptName(temp.getDeptName());
            }
            obj.setRecommenderEmployeeUuid(temp.getRecommenderUuid());
            obj.setRecommenderEmployeeName(temp.getUserName());
            return obj;
        }).collect(Collectors.toList());
        return reqDtoList;
    }
}
